<template>
	<view class="order-person" v-if="personsList && personsList.length > 0">
		<card :title="category+'信息'"> 
			<view class="" v-for="(list, personIndex) in personsList" :key="personIndex">
				<view class="category" v-if="personsList.length > 1">
					{{category + (personIndex+1)}}				
				</view>
				<view class="content">
					<basic-label-value 
						v-for="(item, index) in list"
						:key="index"
						:label="item.name" 
						:value="item.value" 
						color="#999999" 
						size="28rpx" 
						valueColor="#333333"
					/>
				</view>				
			</view>
		</card>
	</view>
</template>
<script>
import card from '../../../components/card'
import { ORDERITEMNAME } from '@/model/enum'
import { formatFild } from 'utils/helper/common'
export default {
	name: 'order-person',
	components: {
		card
	},
	props: {
		persons: { type: Array, default:()=>{return null} },
		category: { type: String, default:'未知' },
	},
	watch: {
		persons:{
			handler:function(val){
				if(!val) return
				this.personsList = []
				for(let i=0; i<val.length; i++) {
					let arr = []
					let item = val[i]
					for(let key in item){
						if(item[key]){
							arr.push({
								name:this.ORDERITEMNAME[key],
								value:formatFild(key,item[key])
							})
						}
					}
					if(arr.length > 0) this.personsList.push(arr)
				}
			},
			deep: true,
			immediate: true
		},
	},
	data() {
		return {
			ORDERITEMNAME,
			personsList:[]
		}
	},
	methods: {
	}
}
</script>
<style lang="less">
.order-person{
	.category{
		font-size: 28rpx;
		color: "#333333";
		line-height: 40rpx;
	}
}
</style>